/* NOTICE
    OpenJaWS - Open Java Weather Station
    
    Copyright (C) 2008 Grant Gardner <grant@lastweekend.com.au>
    
    OpenJaWS is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
NOTICE */
package au.com.lastweekend.openjaws.units;

public enum SIPrefix implements Unit {

    YOTTA(1000000000000000000000000.0, "Y"),
    ZETTA(1000000000000000000000.0, "Z"),
    EXA(1000000000000000000.0, "E"),
    PETA(1000000000000000.0, "P"),
    TERA(1000000000000.0, "T"),
    GIGA(1000000000.0, "G"),
    MEGA(1000000.0, "M"),
    KILO(1000.0, "k"),
    HECTO(100.0, "h"),
    DECA(10.0, "da"),
    DECI(0.1, "d"),
    CENTI(0.01, "c"),
    MILLI(0.001, "m"),
    MICRO(0.000001, "µ"),
    NANO(0.000000001, "n"),
    PICO(0.000000000001, "p"),
    FEMTO(0.000000000000001, "f"),
    ATTO(0.000000000000000001, "a"),
    ZEPTO(0.000000000000000000001, "z"),
    YOCTO(0.000000000000000000000001, "y");

    private String utfSymbol;
    private double multiplier;

    private SIPrefix(double multiplier, String utfSymbol) {

        this.multiplier = multiplier;
        this.utfSymbol = utfSymbol;
    }

    public double convertFrom(double value, Unit unit) {

        return value * ((SIPrefix) unit).multiplier / multiplier;
    }

    public String toString() {

        return utfSymbol;
    }

    public double getMultiplier() {

        return multiplier;
    }
    
    public static void main(String[] args) {
        SIPrefix[] units = SIPrefix.values();
        for (SIPrefix prefix : units) {
            System.out.println(prefix.name() + ":" + prefix.toString());
        }
        
    }
}

